using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace QLNS.Data
{
    public class UngVien_db
    {
        Services m_Ds = new Services();
        public UngVien_db() { }

        public DataTable DanhSachUngVien()
        {
            
            OleDbCommand cmd = new OleDbCommand("SELECT UV.ID AS ID, UV.Ho, UV.TenLot,UV.Ten,UV.NgaySinh,UV.GioiTinh,UV.QuocTich, UV.DanToc,UV.TonGiao,UV.SoCMND,UV.NgayCap,UV.NoiCap,UV.DiaChiThuongTru,UV.DiaChiTamTru,UV.SoDienThoai,UV.TrinhDo,UV.NgoaiNgu,UV.TinHoc,UV.ChinhTri FROM UNGVIEN UV, QUOCTICH QT, DANTOC DT, TONGIAO TG,TRINHDO TD, NGOAINGU NN,TINHOC TH, CHINHTRI CT WHERE UV.QuocTich=QT.ID and UV.DanToc=DT.ID and UV.TonGiao=TG.ID and UV.TrinhDo=TD.ID and UV.NgoaiNgu=NN.ID and UV.TinHoc=TH.ID and UV.ChinhTri=CT.ID"); 
            
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataRow NewRow()
        {
            return m_Ds.NewRow();
        }

        public void Add(DataRow row)
        {
            m_Ds.Rows.Add(row);
        }

        public bool Save()
        {
            return m_Ds.ExecuteNoneQuery() > 0;
        }
        public DataTable TimTheoTen(string ten)
        {
            string sql = "SELECT * FROM UNGVIEN where Ten like '%" + ten + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataTable TimTheoMa(string id)
        {
            string sql = "SELECT * FROM UNGVIEN where ID like '%" + id + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }
    }
}
